import 'package:get/get.dart';
import 'package:homemedia/util/Constant.dart';
import 'package:media_kit/media_kit.dart';
import 'package:media_kit_video/media_kit_video.dart';
import 'package:homemedia/model/media.dart';

class PlayerLogic extends GetxController {
  late VideoInfo video;
  late final player = Player();

  // 播放控制器
  late final mediaKitController = VideoController(player);

  @override
  void onInit() {
    super.onInit();
    video = Get.arguments;
    video.source = "${Constant.apihost}/v1/media/library/item/${video.uuid}/video/${video.type}";
  }

  @override
  void onReady() {
    super.onReady();
    play();
  }

  @override
  void onClose() {
    super.onClose();
    player.dispose();
  }

  @override
  void dispose() {
    super.dispose();
    player.dispose();
  }

  /// 播放TV节目
  void play() {
    String url = video.source!;
    player.open(Media(url));
  }

  void showMenu() {
    //menuController?.forward();
    // Get.dialog(const TvPlayerMenuPage());
  }

  void initData() async {

    update();
  }
}
